package com.my.fo.controller;

import com.my.fo.sse.SSEService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@Controller
@RequestMapping("/sse")
@RequiredArgsConstructor
public class SSEController {

    private final SSEService sseService;

    @GetMapping("/createSse")
    public SseEmitter createSse(String uid) {
        return sseService.crateSse(uid);
    }

    @GetMapping("/closeSse")
    public void closeSse(String uid){
        sseService.closeSse(uid);
    }
}